package com.answer.petsale.controller;

import com.answer.petsale.annotation.AuthCheck;
import com.answer.petsale.common.BaseResponse;
import com.answer.petsale.common.ResultUtils;
import com.answer.petsale.model.vo.DashboardStatsVO;
import com.answer.petsale.service.DashboardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 仪表盘接口
 */
@RestController
@RequestMapping("/dashboard")
@Slf4j
public class DashboardController {

    @Resource
    private DashboardService dashboardService;

    /**
     * 获取仪表盘统计数据
     * @return
     */
    @GetMapping("/stats")
    @AuthCheck(mustRole = "admin") // 确保只有管理员可以访问
    public BaseResponse<DashboardStatsVO> getDashboardStats() {
        DashboardStatsVO stats = dashboardService.getDashboardStats();
        return ResultUtils.success(stats);
    }
}